<template>
  <AmBaseTable ref="AmBaseTableRef"
               :schema="modelSchema"
               :record-config="record"
               @paramsChange="getList"
               :operations="[
                 {
                  label: '导出',
                  auth: ['am:description:export'],
                  clickCB: this.handleExport,
                  buttonProps: {
                    type: 'warning',
                    icon: 'el-icon-download',
                  }
                }
               ]"
               :actions="[
                  {
                    label: '查看',
                    buttonProps: {
                      icon: 'el-icon-view',
                    },
                    clickCB: this.handleReview,
                  },
                ]">
    <template v-slot:column-BLZT="scope">
      <el-tag type="info">{{ BLZTName(scope.row.BLZT) }}</el-tag>
    </template>
  </AmBaseTable>
</template>

<script>
import {delDescription, listDescription, apiListDescription} from "@/api/am/description";
import AmBaseTable from "../../../components/AmComp/AmBaseTable.vue";
import {modelSchema, BLZTOptions} from "./model";
import {isEmpty} from "lodash";

export default {
  name: "Description",
  components: {AmBaseTable},
  data() {
    return {
      modelSchema,
      record: {
        // 显示搜索条件
        showSearch: true,
        data: [],
        total: 0,
        loading: false,
      },
    };
  },
  computed: {
    BLZTName() {
      return state => {
        const target = BLZTOptions.find(item => item.value === state)
        return isEmpty(target) ? '' : target.label
      }
    },
  },
  mounted() {
    this.$nextTick(() => {
      this.getList()
    });
  },
  methods: {
    /** 查询档案著录列表 */
    getList() {
      this.record.loading = true;
      // const queryParams = this.$refs.AmBaseTableRef.getQueryParams();
      // apiListDescription(queryParams).then(response => {
      //   this.record.data = response.rows;
      //   this.record.total = response.total;
      //   this.record.loading = false;
      // });
      setTimeout(() => {
        this.record.data = [
          {
            id: '123',
            "YWH": "业务号", //不可为空
            "QLR": "权利人", //不可为空
            "YWR": "义务人", //不可为空
            "SQSJ": "申请时间", //不可为空
            "SXMC": "事项名称", //不可为空
            "BLJG": "办理结果", //不可为空
            "BLZT": "1", //不可为空，仅显示当前状态，字典表详见下方
            "LCMX": [{
              "LCJD": "流程节点", //字典表详见下方
              "JDZT": "节点状态", //字典表详见下方
              "WCSJ": "完成时间"
            }],
            "FJXX": [{
              "ID": "附件表主键ID",
              "CLMC": "材料名称",
              "BZ": "备注",
              "FJXQ": [{
                "ID": "附件表主键ID",
                "IID": "附件ID",
                "XSMC": "显示名称",
                "ZSMC": "真实名称"
              }]
            }],
            "FJURL": "压缩包下载路径"
          }
        ]
        this.record.loading = false;
      }, 1000)
    },
    /** 查看详情 */
    handleReview(row) {
      this.$router.push({path: `/am/amRemoteQuery/detail/${row.id}`})
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('am/description/export', {
        ...this.queryParams
      }, `description_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
